<script language="JavaScript" type="text/javascript">

function addUploadFiles(){
    var i =  document.getElementById("uploadnum").value;
    i =i*1;
    i=i+1;
 	var  newRowIndex = i + 1;
 document.getElementById("uploadnum").value = i;

   var x=document.getElementById('imagesTabAdd').insertRow(newRowIndex);

   var y=x.insertCell(0);
   var z=x.insertCell(1);
   var a=x.insertCell(2);
   var b=x.insertCell(3);
   y.innerHTML=i;
   z.innerHTML="<input type='file' name='file"+i+"' id='file"+i+"' /></td>";
   a.innerHTML="<input type='text' name='pdesc"+i+"' id='pdesc"+i+"' />";
   b.innerHTML="<input type='checkbox' checked='checked' name='resizeChk"+i+"' id='resizeChk"+i+"' />";
}
</script>

  <table width="100%" border="0" cellpadding="4" cellspacing="0" id="imagesTabAdd">

     <tr>
      <th>Upload Directory</th>
      <th align="left" colspan="2"><input type="text" name="dirname" /></th>

    </tr>
    <tr>
      <th>&nbsp;</th>
      <th align="left">File</th>
      <th>Description</th>
       <th>Resize</th>
    </tr>
    <?php for($i=1;$i<=4;$i++){ ?>
    <tr id="id_<?php echo $i; ?>">
      <td><?php echo $i; ?></td>
      <td><input type="file" name="file<?php echo $i; ?>" id="file<?php echo $i; ?>" /></td>
      <td>
      <input type="text" name="pdesc<?php echo $i; ?>" id="pdesc<?php echo $i; ?>" />
      </td><td>
          <input type="checkbox" checked="checked" name="resizeChk<?php echo $i; ?>" id="resizeChk<?php echo $i; ?>" />
      </td>
    </tr>

    <?php } ?>
    <input type="hidden" value="4" name="uploadnum" id="uploadnum" />
<div id="moreuploads"></div>
    </table>
<a href="#" onclick="addUploadFiles();">Add more image space</a>

